<?php
	require_once('DB.php');
	class person
	{
		protected $uid, $name, $fname, $mname, $dob, $sex, $hno, $street, $city, $pcode, $edu, $email;
		protected $available=0;
		protected $db;
		function __construct()
		{
			include('config.php');
			$dsn = $dbtype.'://'.$user.':'.$pass.'@'.$host.'/'.$db_name;
			$this->db=DB::connect($dsn);
			if (DB::isError($this->db)) {
				die ($this->db->getMessage());
			}
			$this->db->setFetchMode(DB_FETCHMODE_ASSOC);
		}
		

// Is the record available?

		public function isAvailable()
		{
			return $this->available;
		}

// Does a particular UID exist?

		function doesUIdExist($id)
		{
			$sql='select * from person where uid='.$this->db->quoteSmart($id);
			$result=$this->db->query($sql);
			if (DB::isError($result)) {
				die ($result->getMessage());
			}
			$row=$result->fetchRow();
			if($result->numRows()!=0)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}

// Get Set Name
		public function setName($nm)
		{
			$this->name=$nm;
		}
		public function getName()
		{
			return $this->name;
		}
		
// Get Set Father's Name
		public function setFname($nm)
		{
			$this->fname=$nm;
		}
		public function getFname()
		{
			return $this->fname;
		}
		
// Get Set Mother's Name
		public function setMname($nm)
		{
			$this->mname=$nm;
		}
		public function getMname()
		{
			return $this->mname;
		}
		
// Get Set Date of Birth
		public function setDOB($y,$m,$d)
		{
			$this->dob=$y.'-'.$m.'-'.$d;
		}
		public function getDOB()
		{
			return $this->dob;
		}


// Get Set Sex
		public function setSex($value)
		{
			if($value=='M'||$value=='F')
			{
				$this->sex=$value;
				return 1;
			}
			else
			 return 0;
		}
		public function getSex()
		{
			return $this->sex;
		}

// Get Set House Number
		public function setHNo($value)
		{
			$this->hno=$value;
		}
		public function getHNo()
		{
			return $this->hno;
		}


// Get Set Street
		public function setStreet($value)
		{
			$this->street=$value;
		}
		public function getStreet()
		{
			return $this->street;
		}

// Get Set City Name
		public function setCity($value)
		{
			$this->city=$value;
		}
		public function getCity()
		{
			return $this->city;
		}


// Get Set Pin Code
		public function setPinCode($value)
		{
			$this->pcode=$value;
		}
		public function getPinCode()
		{
			return $this->pcode;
		}

// Change Address
		public function changeAddress($h,$s,$c,$p)
		{
			$this->setHNo($h);
			$this->setStreet($s);
			$this->setCity($c);
			$this->setPinCode($p);
		}
	}
?>
